#{extends 'frameHome.html' /}
#{set 'moreScripts'}



<script type="text/javascript">
window.onload = checkStatus;

function unlockTopic(){
	
	var id =${topic.id};
	
	
	$.ajax({
		type: "POST",
		url: '@{Topics.unlockTopic()}',
		data: {'topicId':id}
		});
	document.getElementById('status').setAttribute("href","javascript: lockTopic()"); 
	document.getElementById('status').innerHTML="Lock Topic"
		
	
	
}

function lockTopic(){
	
	var id =${topic.id};
	
	
	$.ajax({
		type: "POST",
		url: '@{Topics.lockTopic()}',
		data: {'topicId':id}
		});
	
	document.getElementById('status').setAttribute("href","javascript: unlockTopic()"); 
	document.getElementById('status').innerHTML="Unlock Topic";
	
	
	
}

function checkStatus(){
	
	#{if topic.isLocked==true}
	document.getElementById('status').setAttribute("href","javascript: unlockTopic()"); 
	document.getElementById('status').innerHTML="Unlock Topic"
	#{/if}
	
		#{if topic.isLocked==false}
		document.getElementById('status').setAttribute("href","javascript: lockTopic()");
		
		document.getElementById('status').innerHTML="Lock Topic"
		#{/if}
}


</script>

#{/set}



<div id="right">

	<p class="field">
		<label>Topic author: </label> ${topic.author.name}
	</p>
	<p class="field">
		<label>Topic title: </label> ${topic.title}
	</p>
	<p class="field">
		<label>Description: </label> ${topic.body}
	</p>
	<p class="field">
		<label>Topic posted on: </label> ${topic.postedAt}
	</p>

	<p class="field">
		<label>Topic execution: </label> ${topic.execution}
	</p>

	<p class="field">
		<label>Topic's entity name: </label> ${topic.entity.entityName}
	</p>
	<p class="field">
		<label>Topic's organization name: </label> ${topic.entity.organization.name}
	</p>

	<p>

#{if topic.execution==false}
		<p><b> Topic is tagged in :

#{if topic.tags}
#{list items:topic.tags, as:'tag'}
<ul>
<li><a href="@{Tags.ShowTag(tag.id)}">${tag.name} </a><a href="@{Tags.unTagSuccess(tagString,tag.id)}" class=" pill button"></span>UnTag Topic</a>
</a></li>
</ul>
#{/list}
#{/if}
#{else}
No Tags !!
#{/else}
</b></p>

<p><b>Organization Tags that Topic is not tagged in:
#{if tagsTopicNotTaggedIn}
#{list items:tagsTopicNotTaggedIn, as:'tag'}
<ul>
<li><a href="@{Tags.ShowTag(tag.id)}">${tag.name} </a><a href="@{Tags.tagSuccess(tagString,tag.id)}" class=" pill button"></span>Tag Topic</a>
</a></li>
</ul>
#{/list}
#{/if}
#{else}
No Tags !!
#{/else}

</b></p>

			
	
		
		#{if inSubscriber==false} <a href="@{Topics.addSubscriber(topic.id)}"
			class="pill button">Follow Topic</a><br /> #{/if} #{if inSubscriber==true} <a
			href="@{Topics.removeSubscriber(topic.id)}" class="pill button">Unfollow Topic</a><br />
		#{/if} 
			
			#{if authorized}
			 <a id=status href="javascript: unlockTopic()" class="pill button">Unlock Topic</a><br />
		 
		
		#{/if}


	</p>
	#{if user!=topic.author}
	#{if isSpammed == false}
	<p class="field">
		<a href="@{Topics.showTopicSpam(topic.id)}" class="pill button"
			onclick="alert ('The Topic has been spammed');">Mark as spam </a>
	</p>
	#{/if} #{else}
	<p class="field">
		<a href="" class="pill button"
			onclick="alert ('This topic is already flagged !');">Mark as spam </a>
	</p>
	#{/else} #{/if}<br>
	<a href="@{PostingIdea.showTopicIdeas(topic.id)}" class="pill button">Show
		Topic Ideas</a><br />

	<a href="@{PostingIdea.Post(topic.id)}"class="pill button"> Post Idea To
			Topic</a><br>
	
	
	<a href="@{Topics.listOfAllTopics(topic.entity.id)}"class="pill button"> Back
			to topics</a><br>
	
	 #{if topic.hide==false}#{if permit}<a
				href="@{Topics.justificationNote(topic.id)}"class="pill button"
				onclick="return confirm ('Are you sure you want to hide this topic?');">
					Hide Topic </a>#{/if}#{/if}<br>
							<a href="@{Entity.viewEntity(topic.entity.id)}"class="pill button"> Back </a><br>



#{if user.email==topic.author.email}
#{if topic.hide==false}
	<a href="@{Topics.showTopicIdeasForExecution(topic.id)}"class="pill button">Execute Button</a><br>
	#{/if}
	#{else}<label>no permissions for execution</label>#{/else}
	#{/if}
	#{else}<label>Topis has been hide</label>#{/else}


#{/if}
#{else}
#{if topic.execution==true}
#{if topic.hide==false}
#{if idea}
#{list items:idea, as:'idea'}
#{if idea.execution==true}
#{if idea.hide==false}
<a href="@{Topics.showIdeaExecuted(idea.id)}"class="pill button">View Idea Executed</a>
#{/if}
#{else}<label>idea is hidden</label>#{/else}
#{/if}#{/list}#{/if}#{/if}#{/if}
#{/else}
</div>
